package gestionSimpleATester;

import static org.junit.Assert.*;

import java.util.Random;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class WithdrawOperationTest {

	WithdrawOperation wo;
	
	@Before
	public void setUp() throws Exception {
		wo = new WithdrawOperation(0);
	}

	@After
	public void tearDown() throws Exception {
		wo = null;
	}

	@Test
	public void testGetOperationType() {
		assertEquals("Withdraw",wo.getOperationType());
	}

	@Test
	public void testWithdrawOperation() {
		try{
			WithdrawOperation x = new WithdrawOperation(-10);
			fail();
		}
		catch(Exception e){}
		
		try{
			// Constructor test If correct the constructor put on the amount the correct value!
			WithdrawOperation x = new WithdrawOperation(0);
			assertEquals(wo.getAmount(), 0);
		}
		catch(Exception e){fail();}
		
		try{
			WithdrawOperation x = new WithdrawOperation(100);
		}
		catch(Exception e){fail();}
		
	}
// Fusion of the tests of get and set 
	@Test
	public void test_Get_Set_Amount() {
		float value;
		for (int i=0;i < 3;i++){
			value = new Random().nextFloat() * 100 ;
			wo.setAmount(value);
			assertEquals(value, wo.getAmount());
		}
		
	}
	
/*
	@Test
	public void testSetAmount() {
		wo.setAmount(0);
		assertEquals(0, wo.getAmount());
		wo.setAmount(-10);
		assertEquals(-10, wo.getAmount());
		wo.setAmount(1);
		assertEquals(1, wo.getAmount());
	}
*/
	
	@Test
	public void testOperation() {
		
	}

}
